<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>结果</title>
    <!--按调用css图层样式-->
    <link rel="stylesheet" type="text/css" href="phpStyle.css">
</head>

<body>
	<h2>所有学生信息</h2>
	<?php
		$servername = "mysql";
		$username = "root";
		$password = "abc123456..";
		$dbname = "studentdb";

		$conn = new mysqli($servername, $username, $password, $dbname);

		if ($conn->connect_error) {
			die("连接失败: " . $conn->connect_error);
		}
	
		$sql = "SELECT * FROM Students";
		$result = $conn->query($sql);
		if ($result->num_rows > 0) {
			echo "<table><tr><th>学号</th><th>姓名</th><th>年龄</th><th>性别</th><th>专业</th></tr>";
			while($row = $result->fetch_assoc()) {
				echo "<tr><td>" . $row["学号"]. "</td><td>" . $row["姓名"]. "</td><td>" . $row["年龄"]. "</td><td>" . $row["性别"]. "</td><td>" . $row["专业"]. "</td></tr>";
			}
			echo "</table>";
		} else {
			echo "没有找到记录<br>";
		}
	
		$conn->close();
    ?>
    
</body>
</html>
